
#include <BRender>
#include <BState>
#include <BMaterial>
#include <BGeoSphere>
#include "member_BGeoSphere.h"

using namespace BWE;

#define member					(*(member_BGeoSphere*)_ptr)
#define member_allocate()		_ptr = new member_BGeoSphere(this)
#define member_release()		delete (member_BGeoSphere*)_ptr

BGeoSphere::BGeoSphere()
{
	member_allocate();
}
BGeoSphere::BGeoSphere(float radius, int divide)
{
	member_allocate();
	this->setRadius(radius);
	this->setSegments(divide);
}
BGeoSphere::~BGeoSphere()
{
	member_release();
}

void BGeoSphere::setRadius(float radius)
{
	if (member.radius != radius)
	{
		member.radius = radius;
		this->dirty();
	}
}
float BGeoSphere::radius() const
{
	return member.radius;
}

void BGeoSphere::setSegments(int segments)
{
	if (member.segments != segments)
	{
		member.segments = segments;
		this->dirty();
	}
}
int BGeoSphere::segments() const
{
	return member.segments;
}

void BGeoSphere::refresh()
{
	BSpace space;
	space.min() = BVector(-member.radius, -member.radius, -member.radius);
	space.max() = BVector(member.radius, member.radius, member.radius);
	this->setSpace(space);
	member.rebuild();
}
